import request from "@/utils/request";
import type { BannerItem, CategoryItem, GuessItem, HotItem, NewItem, Page, PageParams } from "@/types/home";
import type { ResponseType } from "@/types/response";
import type { GoodItem } from "@/types/hot";

enum Enum {
    banner = "/home/banner",
    category = "/home/category/mutli",
    hot = "/home/hot/mutli",
    guess = "/home/goods/guessLike",
    newList = "/home/new"
}

/*获取轮播图的接口*/
export const fetchBannerAPI = (distributionSite: number) => request.get<BannerItem[], ResponseType<BannerItem[]>>(Enum.banner, { params: { distributionSite } });

/*获取分类的接口*/
export const fetchCategoryAPI = (): Promise<ResponseType<CategoryItem[]>> => request.get<CategoryItem, ResponseType<CategoryItem[]>>(Enum.category);

/*获取热门推荐的接口*/
export const fetchHotAPI = (): Promise<ResponseType<HotItem[]>> => request.get<HotItem[], ResponseType<HotItem[]>>(Enum.hot);

/*获取同类推荐的接口*/
export const fetchNewAPI = (limit: number):Promise<ResponseType<NewItem[]>> => request.get<NewItem, ResponseType<NewItem[]>>(Enum.newList, { params: { limit } });

/*获取猜你喜欢的接口*/
export const fetchGuessAPI = (params: PageParams) => request.get<Page<GuessItem[]>, ResponseType<Page<GuessItem[]>>>(Enum.guess, { params });
